package cn.sofwin.dubbo.controller;

import cn.sowfin.dubbo.entity.User;
import cn.sowfin.dubbo.service.GoodsService;
import cn.sowfin.dubbo.service.UserService;
import com.sun.org.apache.xml.internal.utils.StringToIntTable;
import org.apache.dubbo.config.annotation.Reference;
import org.omg.CORBA.StringHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.plaf.synth.SynthToolTipUI;
import java.util.HashMap;
import java.util.Map;
@RestController
public class UserController {
    @Reference
    UserService userService;
    /*@Reference
    GoodsService goodsService;*/


    @GetMapping("/user/login")
    public Map<String,Object> login(String username,String password){
        System.out.println("服务提供者：处理登录请求");
        User user=userService.login2(username,password);
        Map<String,Object> result=new HashMap<>();
        if(user==null){
            result.put("ok",false);
        }else{
            result.put("ok",true);
            result.put("MSG","Welcome"+user.getUsername());
        }
        //获取商品列表
        //result.put("goods",goodsService.goodsList());

        return result;
    }
    @GetMapping("/user/zc2")
    public Map<String,Object> zc2(String username, String password){
        Map<String,Object> result=new HashMap<>();
        userService.zc2(username,password);
        result.put("ok",true);
        return result;
    }

    @GetMapping("/user/zc")
    public Map<String,Object> zc(String username,String password){
        User user=userService.zc(username,password);
        Map<String,Object> result=new HashMap<>();
        if(user==null){
            result.put("ok",false);
        }else{
            result.put("ok",true);
            result.put("MSG","密码"+user.getUsername()+"用户名"+user.getPassword());
        }
        return result;

    }

}
